package vip.xiaonuo;

import cn.hutool.core.exceptions.ExceptionUtil;
import com.xxl.job.core.handler.annotation.XxlJob;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import vip.xiaonuo.core.timer.TimerTaskRunner;
import vip.xiaonuo.facedoor.modular.memberdevice.service.MemberDeviceService;
import vip.xiaonuo.facedoor.modular.visitordevice.service.VisitorDeviceService;

import javax.annotation.Resource;


@Component
@Slf4j
public class DeviceSyncTask implements TimerTaskRunner {


    @Resource
    private MemberDeviceService memberDeviceService;

    @Resource
    private VisitorDeviceService visitorDeviceService;


    @Override
    public void action(String jobParams, String taskId) {
        try {
            memberDeviceService.onKeySync();
        } catch (Exception e) {
            log.error("一键同步人员定时任务发生错误【{}】", ExceptionUtil.getMessage(e));
        }
        try {
            visitorDeviceService.onKeySync();
        } catch (Exception e) {
            log.error("一键同步访客定时任务发生错误【{}】", ExceptionUtil.getMessage(e));
        }
    }

    @Override
    @XxlJob("issuedTask")
    public void executeXxlJob() throws InterruptedException {

    }


}
